package com.xiaoshuidi.cloud.module.report.xxljob.datamanage;

import com.xiaoshuidi.cloud.framework.tenant.core.aop.TenantIgnore;
import com.xiaoshuidi.cloud.module.report.dal.mapper.datamanage.RoomTotalNumMapper;
import com.xiaoshuidi.cloud.module.report.service.datamanage.RoomStatisticsService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 空置房源统计
 */
@Slf4j
@Component
public class RoomStateStatisticsJob {
    @Resource
    private RoomStatisticsService roomStatisticsService;
    @Resource
    private RoomTotalNumMapper roomTotalNumMapper;

    @TenantIgnore
    @Transactional(rollbackFor = Exception.class)
    @XxlJob("update-room-state-statistics")
    public void updateRoomStateStatistics(){
        // 每天插入当天房源的空置房
        roomStatisticsService.insertData();
        // 每天保存当天房源的总数
        roomTotalNumMapper.insertData();
        log.info("[空置房统计] - 插入数据完成");
        log.info("[空置房统计] - 执行结束");
    }
}
